#include <cstdio>

#define max(a,b) (a>b?a:b)

int A[5005];
int DP[5005];

int main() {
	int N;
	int nmax = 0;
	scanf("%d", &N);
	for (int i=1; i<=N; i++) {
		scanf("%d", &A[i]);
		DP[i] = 1;
		for (int j=1; j<i; j++) {
			if (A[i] > A[j]) {
				DP[i] = max(DP[i], DP[j]+1);
			}
		}
		if (DP[i] > nmax) nmax=DP[i];
	}
	printf("%d\n", nmax);
	return 0;
}
